# Maintainer: AlexWMF <alexxwmf@gmail.com>

_realname=tidyhtml
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
# obtain pkgver from http://tidy.cvs.sourceforge.net/tidy/tidy/src/version.h?view=markup
pkgver=1.46
pkgrel=1
pkgdesc="A tool to tidy down your HTML code to a clean style"
arch=("any")
url="https://tidy.sourceforge.io/"
license=('custom')
depends=()
makedepends=("cvs"
            "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=(!strip staticlibs !buildflags)

source=(${_realname}-${pkgver}.tar.bz2
        mappedio_sizecheck.patch
        version_fix.patch)
sha256sums=('SKIP'
            '6e12d8c3c449e57be58c1c90776b34a02136b3cd1904d919f64961abb009f798'
            'e7a922a29f4f917c3370df09c02af52c9ed936610244415d393ba599b841a87b')

mksource() {
  mkdir ${_realname}-${pkgver}
  cd ${_realname}-${pkgver}
  cvs -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy login   #hit enter for password
  cvs -z3 -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy co -P tidy
  cd ..
  tar -cvjf ${_realname}-${pkgver}.tar.bz2 ${_realname}-${pkgver}/*
}

prepare() {
  cd ${_realname}-${pkgver}
  patch -p0 -i ${srcdir}/mappedio_sizecheck.patch
  patch -p0 -i ${srcdir}/version_fix.patch
}

build(){
  cd ${_realname}-${pkgver}/tidy
  source build/gnuauto/setup.sh

  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST}

  make
}

package() {
  cd ${_realname}-${pkgver}/tidy
  make DESTDIR=$pkgdir install

  install -Dm644 htmldoc/license.html \
    "${pkgdir}${MINGW_PREFIX}"/share/licenses/${_realname}/LICENSE
}
